package cn.usian.controller;

import cn.usian.pojo.User;
import cn.usian.service.UserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("{id}")
    public User findById(@PathVariable("id") Long id){
        return userService.findById(id);
    }


    @RequestMapping("findPage")
    public Page<User> findPage(@RequestParam(required = true,defaultValue = "1")Integer pageIndex,String name){
        return userService.findPage(pageIndex,name);
    }

    @RequestMapping("add")
    public void add(@RequestBody User user){
        userService.add(user);
    }

    @RequestMapping("del")
    public void del(Integer id){
        userService.del(id);
    }
}
